import { Controller, Get, Post, Body, Patch, Param, Delete, Request,Headers, Query, HttpCode } from '@nestjs/common';
import { AweiService } from './awei.service';
import { CreateAweiDto } from './dto/create-awei.dto';
import { UpdateAweiDto } from './dto/update-awei.dto';

@Controller({
  path: "awei",
  version: '1'
})
export class AweiController {
  constructor(private readonly aweiService: AweiService) {}

  @Post()
  create(@Body() createAweiDto: CreateAweiDto) {
    return this.aweiService.create(createAweiDto);
  }

  @Get()
  find( @Query('name') query ) {
     return {
       name: query,
       code: 302
     }
  }

  @Get(':id')
  @HttpCode(200)
  findOne(@Param('id') id: string, @Headers() header) {
    console.log('header=>',header)
    return {
      code: 201,
      id: id,
      header: header.cookie
    }
    return this.aweiService.findOne(+id);
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateAweiDto: UpdateAweiDto) {
    return this.aweiService.update(+id, updateAweiDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.aweiService.remove(+id);
  }
}
